package com.ad.pet.app.account.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ad.pet.R;
import com.ad.pet.common.data.utils.glide.GlideUtil;
import com.ad.pet.models.remote.account.AccountPet;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by liuyixiang on 2019/10/26.
 */

public class AccountPetAdapter extends BaseQuickAdapter<AccountPet,BaseViewHolder> {
    public AccountPetAdapter(@Nullable List<AccountPet> data) {
        super(R.layout.item_pet_head_layout, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, AccountPet item) {
        ImageView ivHead = helper.getView(R.id.iv_head);
        TextView tvTitle = helper.getView(R.id.tv_add);
        ImageView ivBack = helper.getView(R.id.iv_back);
        if ("-1".equals(item.getPet_id())){
            tvTitle.setVisibility(View.VISIBLE);
            ivHead.setImageResource(R.color.bg_color);
        }else {
            tvTitle.setVisibility(View.GONE);
            GlideUtil.load(mContext,item.getPet_headimg(),ivHead);
        }
        if (item.isChose()){
            ivBack.setBackgroundResource(R.drawable.ic_chose_pet_head);
        }else {
            ivBack.setBackgroundResource(R.drawable.ic_default_pet_bg);
        }
    }
}
